package com.ggboy.item_bank.service.imp;

import com.ggboy.item_bank.beans.BigQst;
import com.ggboy.item_bank.beans.ChoiceQst;
import com.ggboy.item_bank.beans.DesignQst;
import com.ggboy.item_bank.beans.TOFQst;
import com.ggboy.item_bank.dao.*;
import com.ggboy.item_bank.service.TestService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Service
public class TestServiceImpl implements TestService {
    @Resource
    private ChoiceQstDao choiceQstDao;

    @Resource
    private DesignQstDao designQstDao;

    @Resource
    private TOFQstDao tofQstDao;
    @Resource
    private BigQstDao bigQstDao;

    public List<ChoiceQst> selectChoiceListById1(String[] choiceTests) {//根据id查找选择题表
        ArrayList<ChoiceQst> choiceQsts = new ArrayList<>();//用于装每到题的javaBean对象
        for (String i :
                choiceTests) {
            ChoiceQst choiceQst = choiceQstDao.selectChoiceQstById(i);//根据ID查找每道题的javaBean对象
            choiceQsts.add(choiceQst);//把javaBean对象存进集合里
        }
        return choiceQsts;
    }

    public List<TOFQst> selectTOFListById1(String[] tofTests) {//根据id查找判断题表
        ArrayList<TOFQst> tofQsts = new ArrayList<>();
        for (String i :
                tofTests) {
            TOFQst tofQst = tofQstDao.selectTOFQstById(i);
            tofQsts.add(tofQst);
        }
        return tofQsts;
    }

    public List<DesignQst> selectDesignListById1(String[] designTests) {//根据id查找简答题表
        ArrayList<DesignQst> designQsts = new ArrayList<>();
        for (String i :
                designTests) {
            DesignQst designQst = designQstDao.selectDesQstById(i);
            designQsts.add(designQst);
        }
        return designQsts;
    }

    public List<BigQst> selectBigListById1(String[] bigTests) {//根据id应用题表
        ArrayList<BigQst> bigQsts = new ArrayList<>();
        for (String i :
                bigTests) {
            BigQst bigQst = bigQstDao.selectBigQstById(i);
            bigQsts.add(bigQst);
        }
        return bigQsts;
    }
}
